<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div>{{name}}</div>
        <!-- innerHTML -->
        <div v-html="page"></div>
        <!-- dispaly控制 -->
        <div v-show="flag">v-show</div>
        <!-- 条件创建和移除元素 -->
        <div v-if="flag">v-if</div>
        <!-- <div v-else-if>v-else-if</div>
        <div v-else>v-else</div> -->

        <!-- 事件触发 -->
        <!-- 内联 -->
        <div>
            <button v-on:click="count--">-</button>
            {{count}}
            <button v-on:click="count = count + 2">+</button>
            <!-- v-on:click = @ -->
            <button @click="count = count * 2">*</button>

            <!-- methods函数 -->
            <button @click="fn(2)">methods函数 右移1位</button>
        </div>
        <!-- v-bind   src url title ...-->
        <div>
            <a v-bind:href ="imgUrl">动态网站</a>
        </div>

        <!-- v-for -->
        <div>
            <ul>
                <li v-for="(item, index) in foods" :key="item.id">
                    {{item.name}} -- {{index}}
                </li>
            </ul>
        </div>

        <!-- v-model -->
        账号:<input type="text" v-model="username"> <br><br>
        密码:<input type="password" v-model="password"> <br><br>
        <button>登录</button>
        <button>重置</button>
    </div>

    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
    <script>
        const vue = new Vue({
            el: '#app',
            data: {
                name: 'dcj',
                age: 123,
                page: '<a href= "http://www.baidu.com"> 百度网站 </a>',
                flag: true,
                count: 100,
                imgUrl: 'http://www.csdn.com',
                foods: [{id: 1, name:'dcj'},{id : 2, name : 'axios'}],
                username: '',
                password: ''
            },
            methods: {
                fn(mod) {
                    this.count /= mod
                }
            }
        })
    </script>
</body>

</html>